#博客详情页(当前用户登录）
import time

from selenium import webdriver
from selenium.webdriver.common.by import By

from common.Utils import  BlogDriver

class Blogdetil:
    url=""
    driver=""
    def __init__(self):
        self.url="http://8.137.19.140:9090/blog_detail.html?blogId=92939"
        self.driver=BlogDriver.driver
        self.driver.get(self.url)
    def DetilRigText(self):
        #检查标题
        time.sleep(1)
        text= self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div > div.title").text
        print(text)
          #时间
        text1=self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div > div.date").text
        print(text1)
        #内容
        text2=self.driver.find_element(By.CSS_SELECTOR,"#h2-u5728u8FD9u91CCu5199u4E0Bu4E00u7BC7u535Au5BA2").text
        print(text2)
        #删除
        text3=self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div > div.operating > button:nth-child(1)").text
        print(text3)
        text4=self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div > div.operating > button:nth-child(2)").text
        print(text4)
        BlogDriver.getScreenshot()
    def DeleteText(self):
        time.sleep(1)

        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div > div.operating > button:nth-child(2)").click()
        alert = self.driver.switch_to.alert

        assert alert.text == "确定删除?"
        # 确认删除
        alert.accept()

        ter=self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > h3").text
        print(ter)


